package com.base.component.ai.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.base.component.ai.system.dao.FlowRunDao;
import com.base.component.ai.system.entity.FlowConfigureDO;
import com.base.component.ai.system.entity.FlowRunDO;
import com.base.component.ai.system.service.FlowConfigureService;
import com.base.component.ai.system.service.FlowRunService;
import com.base.core.framework.sql.service.impl.SqlBaseServiceImplV1Ext;


/**
 * @author zywei 
 * @date 2025-01-11 11:56:16
 */
@Service("flowRunService")
public class FlowRunServiceImpl extends SqlBaseServiceImplV1Ext<FlowRunDO,Long> 
implements FlowRunService {

	final FlowRunDao flowRunDao;
	@Autowired
	private FlowConfigureService flowConfigureService;
	
	public FlowRunServiceImpl(@Qualifier("flowRunDao")FlowRunDao flowRunDao) {
		super(flowRunDao);
		this.flowRunDao=flowRunDao;
	}

	@Override
	public Long run(Long flowConfigureId) {
		FlowConfigureDO flowConfigure=flowConfigureService.load(flowConfigureId);
		FlowRunDO flowRun=new FlowRunDO();
		flowRun.setFlowConfigureId(flowConfigureId);
		flowRun.setInputParams(flowConfigure.getInputParams());
		flowRun.setNexts(flowConfigure.getNexts());
		save(flowRun);
		return flowRun.getId();
	}

}
